// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Aggregations;

public sealed partial class BucketCorrelationFunctionCountCorrelation
{
	/// <summary>
	/// <para>The indicator with which to correlate the configured `bucket_path` values.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("indicator")]
	public Elastic.Clients.Elasticsearch.Aggregations.BucketCorrelationFunctionCountCorrelationIndicator Indicator { get; set; }
}

public sealed partial class BucketCorrelationFunctionCountCorrelationDescriptor : SerializableDescriptor<BucketCorrelationFunctionCountCorrelationDescriptor>
{
	internal BucketCorrelationFunctionCountCorrelationDescriptor(Action<BucketCorrelationFunctionCountCorrelationDescriptor> configure) => configure.Invoke(this);

	public BucketCorrelationFunctionCountCorrelationDescriptor() : base()
	{
	}

	private Elastic.Clients.Elasticsearch.Aggregations.BucketCorrelationFunctionCountCorrelationIndicator IndicatorValue { get; set; }
	private Elastic.Clients.Elasticsearch.Aggregations.BucketCorrelationFunctionCountCorrelationIndicatorDescriptor IndicatorDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Aggregations.BucketCorrelationFunctionCountCorrelationIndicatorDescriptor> IndicatorDescriptorAction { get; set; }

	/// <summary>
	/// <para>The indicator with which to correlate the configured `bucket_path` values.</para>
	/// </summary>
	public BucketCorrelationFunctionCountCorrelationDescriptor Indicator(Elastic.Clients.Elasticsearch.Aggregations.BucketCorrelationFunctionCountCorrelationIndicator indicator)
	{
		IndicatorDescriptor = null;
		IndicatorDescriptorAction = null;
		IndicatorValue = indicator;
		return Self;
	}

	public BucketCorrelationFunctionCountCorrelationDescriptor Indicator(Elastic.Clients.Elasticsearch.Aggregations.BucketCorrelationFunctionCountCorrelationIndicatorDescriptor descriptor)
	{
		IndicatorValue = null;
		IndicatorDescriptorAction = null;
		IndicatorDescriptor = descriptor;
		return Self;
	}

	public BucketCorrelationFunctionCountCorrelationDescriptor Indicator(Action<Elastic.Clients.Elasticsearch.Aggregations.BucketCorrelationFunctionCountCorrelationIndicatorDescriptor> configure)
	{
		IndicatorValue = null;
		IndicatorDescriptor = null;
		IndicatorDescriptorAction = configure;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (IndicatorDescriptor is not null)
		{
			writer.WritePropertyName("indicator");
			JsonSerializer.Serialize(writer, IndicatorDescriptor, options);
		}
		else if (IndicatorDescriptorAction is not null)
		{
			writer.WritePropertyName("indicator");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Aggregations.BucketCorrelationFunctionCountCorrelationIndicatorDescriptor(IndicatorDescriptorAction), options);
		}
		else
		{
			writer.WritePropertyName("indicator");
			JsonSerializer.Serialize(writer, IndicatorValue, options);
		}

		writer.WriteEndObject();
	}
}